package com.cn.algorithm02.class04;

/***
 * @author: hels
 * @description:
 **/
public class NodeDouble {
    int value;
    NodeDouble last;
    NodeDouble next;
    public NodeDouble(int value){
        this.value = value;
    }

    static NodeDouble getHead() {
        NodeDouble dNode1 = new NodeDouble(1);
        NodeDouble dNode2 = new NodeDouble(2);
        NodeDouble dNode3= new NodeDouble(3);
        dNode1.next = dNode2;
        dNode2.last = dNode1;
        dNode2.next = dNode3;
        dNode3.last = dNode2;
        return dNode1;
    }

    @Override
    public String toString() {
        Integer lastValue = null;
        Integer nextValue = null;
        if (last != null) {
            lastValue = last.value;
        }
        if (next != null) {
            nextValue = next.value;
        }


        return "NodeDouble{" +
                "value=" + value +
                ", last=" + lastValue +
                ", next=" + nextValue +
                '}';
    }
}
